package com.geeksaga.domain;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.collections.FactoryUtils;
import org.apache.commons.collections.ListUtils;
import org.springframework.web.multipart.MultipartFile;

import com.geeksaga.annotation.PrintToString;
import com.geeksaga.common.util.HtmlUtil;
import com.geeksaga.common.util.Util;

/**
 * @author newbie
 * @since 0.1
 */
@SuppressWarnings("unchecked")
public class Bbs extends BaseObject {

    private static final long serialVersionUID = 4978301248293140828L;

    public static enum CNT_TYPE { VIEW_PLUS_CNT, MEMO_PLUS_CNT, VIEW_MINUS_CNT, MEMO_MINUS_CNT, TAG_PLUS_CNT, RATE_PLUS_CNT, STAR_PLUS_CNT };
	
	@PrintToString private String no;
	@PrintToString private String sid;
	@PrintToString private String bbsSid;
    @PrintToString private String bbsNo;
	@PrintToString private int partitionNo;
	@PrintToString private int categoryPartitionNo;
    @PrintToString private String categorySid;
	@PrintToString private String bbsId;
	@PrintToString private String bbsName;
    @PrintToString private String depth;
	@PrintToString private String bbsIcon;
	@PrintToString private String userSid;
	@PrintToString private String userPasswd;
	@PrintToString private String userNick;
	@PrintToString private String userIcon;
	@PrintToString private String userIp;
	@PrintToString private String userEmail;
	@PrintToString private String userHomepage;
	@PrintToString private String userCountry;
	@PrintToString private String title;
	@PrintToString private String content;
	@PrintToString private String viewCnt;
	@PrintToString private String memoCnt;
	@PrintToString private String fileCnt;
	@PrintToString private String tagCnt;
	@PrintToString private String goodSum;
	@PrintToString private String goodCnt;
	@PrintToString private String starSum;
	@PrintToString private String starCnt;
	@PrintToString private String pollCnt;
	@PrintToString private String delYn;
	@PrintToString private String noticeYn;
	@PrintToString private String bestYn;
	@PrintToString private String secretYn;
	@PrintToString private String editYn;
	@PrintToString private String pollStart;
	@PrintToString private String pollEnd;
	@PrintToString private String tagName;
	@PrintToString private String tagSid;
	@PrintToString private String thumbnailImg;
	@PrintToString private String registDate;
	@PrintToString private String registTime;
	@PrintToString private String registTimestamp;
	@PrintToString private String modifyDate;	
	@PrintToString private String modifyTime;
	@PrintToString private String modifyTimestamp;
	@PrintToString
	private List<SagaFile> fileList = new ArrayList<SagaFile>();
	@PrintToString
	private List<MultipartFile> file = new ArrayList<MultipartFile>();
	@PrintToString
	private List<Memo> memoList = ListUtils.lazyList(new ArrayList<Memo>(), FactoryUtils.instantiateFactory(Memo.class));
	@PrintToString
	private List<Tag> tagList = ListUtils.lazyList(new ArrayList<Tag>(), FactoryUtils.instantiateFactory(Tag.class));

    public Bbs() {
	}
	
    public Bbs(String bbsNo) {
        this.bbsNo = bbsNo;
    }
    
	public Bbs(String bbsNo, String bbsId) {
	    this.bbsNo = bbsNo;
	    this.bbsId = bbsId;
	}
	
	public String getIndexingData() {
		StringBuilder sb = new StringBuilder();
		sb.append(getTitle());
		sb.append("\r\n");
		sb.append(getUserNick());
		sb.append("\r\n");
		sb.append(HtmlUtil.removeTag(getContent()));
		
		Iterator<SagaFile> iterator = getFileList().iterator();
		
		while(iterator.hasNext()) {
		    sb.append("\r\n");
			sb.append(iterator.next().getOriginalName());
		}
		
		return sb.toString();
	}
	
	public String getIp() {
		return Util.hideIp(userIp);
	}
	
	public String getNo() {
		return no;
	}

	public void setNo(String no) {
		this.no = no;
	}

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getBbsSid() {
        return bbsSid;
    }

    public void setBbsSid(String bbsSid) {
        this.bbsSid = bbsSid;
    }
    
	public String getBbsNo() {
		return bbsNo;
	}

	public void setBbsNo(String bbsNo) {
		this.bbsNo = bbsNo;
	}

    public int getPartitionNo() {
        return partitionNo;
    }

    public void setPartitionNo(int partitionNo) {
        this.partitionNo = partitionNo;
    }

    public int getCategoryPartitionNo() {
        return categoryPartitionNo;
    }

    public void setCategoryPartitionNo(int categoryPartitionNo) {
        this.categoryPartitionNo = categoryPartitionNo;
    }
    
	public String getCategorySid() {
		return categorySid;
	}

	public void setCategorySid(String categorySid) {
		this.categorySid = categorySid;
	}

	public String getBbsId() {
		return bbsId;
	}

	public void setBbsId(String bbsId) {
		this.bbsId = bbsId;
	}

    public String getBbsName() {
        return bbsName;
    }

    public void setBbsName(String bbsName) {
        this.bbsName = bbsName;
    }
	
	public String getDepth() {
		return depth;
	}

	public void setDepth(String depth) {
		this.depth = depth;
	}

	public String getBbsIcon() {
		return bbsIcon;
	}

	public void setBbsIcon(String bbsIcon) {
		this.bbsIcon = bbsIcon;
	}

	public String getUserSid() {
		return userSid;
	}

	public void setUserSid(String userSid) {
		this.userSid = userSid;
	}

	public String getUserPasswd() {
		return userPasswd;
	}

	public void setUserPasswd(String userPasswd) {
		this.userPasswd = userPasswd;
	}

	public String getUserNick() {
		return userNick;
	}

	public void setUserNick(String userNick) {
		this.userNick = userNick;
	}

	public String getUserIcon() {
		return userIcon;
	}

	public void setUserIcon(String userIcon) {
		this.userIcon = userIcon;
	}

	public String getUserIp() {
		return userIp;
	}

	public void setUserIp(String userIp) {
		this.userIp = userIp;
	}

	public String getUserEmail() {
		return userEmail;
	}

	public void setUserEmail(String userEmail) {
		this.userEmail = userEmail;
	}

	public String getUserHomepage() {
		return userHomepage;
	}

	public void setUserHomepage(String userHomepage) {
		this.userHomepage = userHomepage;
	}

	public String getUserCountry() {
		return userCountry;
	}

	public void setUserCountry(String userCountry) {
		this.userCountry = userCountry;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getViewCnt() {
		return viewCnt;
	}

	public void setViewCnt(String viewCnt) {
		this.viewCnt = viewCnt;
	}

	public String getMemoCnt() {
		return memoCnt;
	}

	public void setMemoCnt(String memoCnt) {
		this.memoCnt = memoCnt;
	}

	public String getFileCnt() {
		return fileCnt;
	}

	public void setFileCnt(String fileCnt) {
		this.fileCnt = fileCnt;
	}

	public String getTagCnt() {
		return tagCnt;
	}

	public void setTagCnt(String tagCnt) {
		this.tagCnt = tagCnt;
	}

	public String getGoodSum() {
		return goodSum;
	}

	public void setGoodSum(String goodSum) {
		this.goodSum = goodSum;
	}

	public String getGoodCnt() {
		return goodCnt;
	}

	public void setGoodCnt(String goodCnt) {
		this.goodCnt = goodCnt;
	}

	public String getStarSum() {
		return starSum;
	}

	public void setStarSum(String starSum) {
		this.starSum = starSum;
	}

	public String getStarCnt() {
		return starCnt;
	}

	public void setStarCnt(String starCnt) {
		this.starCnt = starCnt;
	}

	public String getPollCnt() {
		return pollCnt;
	}

	public void setPollCnt(String pollCnt) {
		this.pollCnt = pollCnt;
	}

	public String getDelYn() {
		return delYn;
	}

	public void setDelYn(String delYn) {
		this.delYn = delYn;
	}

	public String getNoticeYn() {
		return noticeYn;
	}

	public void setNoticeYn(String noticeYn) {
		this.noticeYn = noticeYn;
	}

	public String getBestYn() {
		return bestYn;
	}

	public void setBestYn(String bestYn) {
		this.bestYn = bestYn;
	}

	public String getSecretYn() {
		return secretYn;
	}

	public void setSecretYn(String secretYn) {
		this.secretYn = secretYn;
	}

	public String getEditYn() {
		return editYn;
	}

	public void setEditYn(String editYn) {
		this.editYn = editYn;
	}

	public String getPollStart() {
		return pollStart;
	}

	public void setPollStart(String pollStart) {
		this.pollStart = pollStart;
	}

	public String getPollEnd() {
		return pollEnd;
	}

	public void setPollEnd(String pollEnd) {
		this.pollEnd = pollEnd;
	}

	public String getTagName() {
		return tagName;
	}

	public void setTagName(String tagName) {
		this.tagName = tagName;
	}

	public String getTagSid() {
		return tagSid;
	}

	public void setTagSid(String tagSid) {
		this.tagSid = tagSid;
	}

	public String getThumbnailImg() {
		return thumbnailImg;
	}

	public void setThumbnailImg(String thumbnailImg) {
		this.thumbnailImg = thumbnailImg;
	}

	public String getRegistDate() {
		return registDate;
	}

	public void setRegistDate(String registDate) {
		this.registDate = registDate;
	}

	public String getRegistTime() {
		return registTime;
	}

	public void setRegistTime(String registTime) {
		this.registTime = registTime;
	}

	public String getModifyDate() {
		return modifyDate;
	}

	public void setModifyDate(String modifyDate) {
		this.modifyDate = modifyDate;
	}

	public String getModifyTime() {
		return modifyTime;
	}

	public void setModifyTime(String modifyTime) {
		this.modifyTime = modifyTime;
	}

	public String getRegistTimestamp() {
		return registTimestamp;
	}

	public void setRegistTimestamp(String registTimestamp) {
		this.registTimestamp = registTimestamp;
	}

	public String getModifyTimestamp() {
		return modifyTimestamp;
	}

	public void setModifyTimestamp(String modifyTimestamp) {
		this.modifyTimestamp = modifyTimestamp;
	}

    public List<SagaFile> getFileList() {
		return fileList;
	}

	public void setFileList(List<SagaFile> fileList) {
		this.fileList = fileList;
	}

	public List<MultipartFile> getFile() {
		return file;
	}

	public void setFile(List<MultipartFile> file) {
		this.file = file;
	}

	public List<Memo> getMemoList() {
		return memoList;
	}

	public void setMemoList(List<Memo> memoList) {
		this.memoList = memoList;
	}

    public List<Tag> getTagList() {
        return tagList;
    }

    public void setTagList(List<Tag> tagList) {
        this.tagList = tagList;
    }
}